<?php
class Get_time extends CI_Model {

    function __construct(){
        parent::__construct();

        }
function ago($now,$timestamp){
    
        $difference = $now - $timestamp;
        if($difference < 60)
            return $difference." seconds ago";
        else{
            $difference = round($difference / 60);
            if($difference < 60)
                return $difference." minutes ago";
            else{
                $difference = round($difference / 60);
                if($difference < 24)
                    return $difference." hours ago";
                else{
                    $difference = round($difference / 24);
                    if($difference < 7)
                        return $difference." days ago";
                    else{
                        $difference = round($difference / 7);
                        return $difference." weeks ago";
                    }
                }
            }
        }
    }
}
?>
